package com.sywb.chuangyebao.view;

import com.alibaba.fastjson.JSON;
import com.sywb.chuangyebao.bean.Comment;
import com.sywb.chuangyebao.contract.BaseNewsDetailContract;
import com.sywb.chuangyebao.contract.SupportCommentDetailContract;
import com.sywb.chuangyebao.view.dialog.CommentReplyDialog;

/**
 * 支持我的评论跳转到评论详情
 * Created by duxl on 2018/5/9.
 */

public abstract class SupportCommentDetailActivity<T extends BaseNewsDetailContract.BasePresenter> extends ActionbarActivity<T> implements SupportCommentDetailContract.View {

    // 如果返回值不为null，表示从个人中心我的评论进入，当加载完文章（或视频、或其他内容）后需要自动弹出CommentReplyDialog
    public abstract Comment getComment();

    @Override
    public void showCommentRelyDialog() {
        if(getComment() != null) {
            String topicType = mPresenter.getTopicType();
            // position传-1，表示弹出Dialog添加评论后，返回到详情页面，评论列表不更新评论数量
            // 因为通过showCommentRelyDialog方法弹出的评论，在NewsDetailActivity页面底部不一定有改条评论
            final int position = -1;
            CommentReplyDialog dialogFragment = CommentReplyDialog.newInstance(getDialogViewHeight(), JSON.toJSONString(getComment()), position, topicType);
            dialogFragment.show(getMyFragmentManager(), topicType);
        }
    }
}
